#pragma once

#include <string>
#include <cstdlib>
#include <cstdio>
#include <cerrno>
#include <stdarg.h>

#include "pugixml/pugixml.hpp"

#include "topcvt_common.hpp"
#include "topcvt_logutil.hpp"
#include "topcvt_component.hpp"
#include "topcvt_cross_platform.hpp"

using namespace std;
using namespace topcvt;

#include "logcplus/logcplus.h"

#define maxBuffSize 8192
#define XML_PARSE_STATUS_INFO(status) xmlErrorInfo(status).c_str()

void  format_args(char* sbuf, const char* fmt, ...);

#define infoLog(fmt, ...) \
    {\
        char sbuf[maxBuffSize] = { 0 }; \
        format_args(sbuf,fmt,##__VA_ARGS__);\
        printf("%s\n", sbuf); \
        TLOG_INFO("%s",sbuf); \
    }\

#define errorLog(fmt, ...) \
    {\
        char sbuf[maxBuffSize] = { 0 }; \
        format_args(sbuf,fmt,##__VA_ARGS__);\
        printf("%s\n", sbuf); \
        TLOG_INFO("%s",sbuf); \
    }\    

#define pexit_info(fmt, ...) \    
{\
    char sbuf[maxBuffSize] = { 0 }; \
    format_args(sbuf,fmt,##__VA_ARGS__);\
    printf("%s\n", sbuf); \
    exit_system(0);\
}\

string xmlErrorInfo(pugi::xml_parse_status xmlStatus);